/**
 * Created by ebalmes Oct 6, 2009 10:03:15 AM
 * 
 */
package gui.dialogs.panels;

import gui.table.SearchPatientTable;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.Border;

import model.table.SearchPatientTableModel;

public class SearchPatientPanel extends JPanel implements KeyListener
{
  private JTextField searchField = new JTextField(10);
  private SearchPatientTableModel model;

  public SearchPatientPanel(SearchPatientTableModel model) {
    this.model = model;
    setLayout(new BorderLayout());
    add(createTable(), BorderLayout.CENTER);
    add(createSearchPanel(), BorderLayout.NORTH);
    searchField.addKeyListener(this);
    
  }
  
  public JPanel createSearchPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());
    panel.add(searchField);
    panel.add(new JButton("Search"));
    return panel;
  }
  
  public JScrollPane createTable() {
    
    SearchPatientTable table = new SearchPatientTable(model);
    JScrollPane pane = new JScrollPane(table);
    return pane;
  }

  @Override
  public void keyPressed(KeyEvent e) {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void keyReleased(KeyEvent e) {
    model.searchFieldChanged(searchField.getText());  
  }

  @Override
  public void keyTyped(KeyEvent e) {
    // TODO Auto-generated method stub
    
  }
}
